package utilities.display.shapes.definedshapes;

import java.awt.Color;
import java.awt.Composite;
import java.awt.Polygon;
//import java.awt.Point;
//import java.awt.Rectangle;
import java.awt.Stroke;

import utilities.display.shapes.DrawShape;

/**
 * 
 * @author CoconutTank
 *
 */
public class DrawCircle extends DrawShape
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -5952001837262369165L;
	
	protected int x;
	
	protected int y;

	/**
	 * 
	 * @param x
	 * @param y
	 * @param radius
	 * @param lineColor
	 * @param stroke
	 * @param lineComposite
	 * @param fillColor
	 * @param fillComposite
	 */
	public DrawCircle(int x, int y, int radius, Color lineColor, 
					Stroke stroke, Composite lineComposite, 
					Color fillColor, Composite fillComposite)
	{
		super(new Polygon(), lineColor, stroke, lineComposite, fillColor, fillComposite);
		
		for(double ang = 0.0; ang < 360.0; ang++)
		{
			// Get X
			int px = (int)(Math.cos(Math.PI * ang / 180.0) * radius) + x;
			
			// Get Y
			int py = (int)(Math.sin(Math.PI * ang / 180.0) * radius) + y;
			
			// Add this point to the polygon
			((Polygon)myShape).addPoint(px, py);
		}
		
		this.x = x;
		this.y = y;
	}
	
	public int getX() { return x; }
	
	public int getY() { return y; }
	
	public void translate(int dx, int dy)
	{
		((Polygon)myShape).translate(dx, dy);
	}
	
	public void setLocation(int x, int y)
	{
		int dx = x - this.x;
		int dy = y - this.y;
		
		this.x = x;
		this.y = y;
		
		translate(dx, dy);
	}
}
